package com.hqbzl.c1;

import com.sun.jdi.IntegerValue;
import lombok.extern.slf4j.Slf4j;

import java.io.UnsupportedEncodingException;
import java.lang.instrument.Instrumentation;
import java.nio.ByteBuffer;
import java.util.concurrent.locks.LockSupport;

@Slf4j(topic = "TestLockSupport")
public class TestLockSupport {
    public static void main12(String[] args) {
        String str = "中";
        char x = '中';
        byte[] bytes = null;
        byte[] bytes1 = null;
        try {
            bytes = str.getBytes("utf-8");
            bytes1 = charToByte(x);
            System.out.println("bytes 大小：" + bytes.length);
            System.out.println("bytes1大小：" + bytes1.length);
        } catch (UnsupportedEncodingException e) {// TODO Auto-generated
            e.printStackTrace();
        }
    }

    public static byte[] charToByte(char c) {
        byte[] b = new byte[2];
        b[0] = (byte) ((c & 0xFF00) >> 8);
        b[1] = (byte) (c & 0xFF);
        return b;
    }

    public static void main(String[] args) {
        //Instrumentation is = new InstrumentationImpl();

    }
    public static void main44(String[] args) {
        int bytes = Character.SIZE / 8;
        System.out.println("char类型的字节数为：" + bytes);
        final int size = Integer.SIZE;
        final int len = Integer.SIZE / Byte.SIZE;
        System.out.println("len = " + len);
        //test();
        int a = 0;
        int b = 0;
        if (a > 0 && b == 0) {
            System.out.println("ok");
        }
        Integer av = Integer.valueOf(1);
        final ByteBuffer buffer = ByteBuffer.allocateDirect(64);
        Integer[] arr = {};
        System.out.println("arr.length = " + arr.length);
        char c = '1';
    }

    private static void test() {
        final Thread thread = new Thread(() -> {
            log.debug("park....");
            // 打断标记为假会停下来
            LockSupport.park();
            log.debug("unpark...");
            log.debug("status: {}", Thread.currentThread().isInterrupted());
        }, "t1");
        thread.start();
        TestCreate.sleep(1);
        // thread.interrupt();
    }
}
